package com.cheung.leetcode.normal;

import java.util.ArrayList;
import java.util.List;

public class LC78 {

    public static List<List<Integer>> subsets(int[] nums) {
        List<List<Integer>> result = new ArrayList<>();
        List<Integer> path = new ArrayList<>();
        backtracking(result, path, nums, 0);
        return result;
    }

    private static void backtracking(List<List<Integer>> result, List<Integer> path, int[] nums, int begin) {
        result.add(new ArrayList<>(path));
        for (int i = begin; i < nums.length; i++) {
            path.add(nums[i]);
            backtracking(result, path, nums, i + 1);
            path.remove(path.size() - 1);
        }

    }

    public static void main(String[] args) {
        System.out.println(subsets(new int[]{1, 2, 3}));
    }
}
